package com.practice.designMode.coupon;

import com.alibaba.fastjson2.JSONObject;

import java.math.BigDecimal;

public class FullReductionStrategy implements CouponRuleStrategy{
    @Override
    public boolean validate(Order order, UserCoupon userCoupon, JSONObject ruleJson) {
        // 校验满减门槛`
        BigDecimal threshold = ruleJson.getBigDecimal("threshold");
        return order.getAmount().compareTo(threshold) >= 0;
    }

    @Override
    public CouponType supportCouponType() {
        return CouponType.FULL;
    }
}
